<html>
    <head>
        <meta charset="utf-8">
        <script src="../dist/claygl.js"></script>
    </head>
    <body style="margin:0px;">
        <canvas width="1200" height="640" id="main"></canvas>
        <script>
            var Shader = clay.Shader;

            var renderer = new clay.Renderer({
                canvas: document.getElementById('main'),
                devicePixelRatio: 1.0
            });
            renderer.resize(window.innerWidth, window.innerHeight);

            var scene = new clay.Scene;
            var camera = new clay.camera.Perspective({
                aspect: renderer.getViewportAspect(),
                far: 500
            });

            var shader = clay.shader.library.get("clay.basic");

            var material = new clay.Material({
                shader: shader
            });
            var image = new Image;
            image.src = "assets/textures/ground_tile.jpg";
            var texture = new clay.Texture2D({
                image: image,
                wrapS: clay.Texture.REPEAT,
                wrapT: clay.Texture.REPEAT,
                anisotropic: 16
            });
            image.onload = function(){
                texture.dirty();
            };
            material.set("diffuseMap", texture);
            material.set("uvRepeat", [10, 10])

            var root = new clay.Node();

            camera.position.set(0, 4, 14);
            camera.lookAt( new clay.Vector3(0, 1, 0) );

            scene.add( root );
            // Add Plane
            var plane = new clay.geometry.Plane({
                widthSegments: 1,
                heightSegments: 1
            });
            var planeMesh = new clay.Mesh({
                geometry: plane,
                material: material,
                scale: new clay.Vector3(60, 60, 60)
            });
            planeMesh.position.y = -0.8;
            planeMesh.rotation.rotateX(-Math.PI/2);
            root.add(planeMesh);

            setInterval(function () {
                renderer.render(scene, camera);
            }, 20);

        </script>
    </body>
</html>